Skip to content

fix: report full per-prompt token usage - #353

Open
zfy0701 wants to merge 1 commit into
agentclientprotocol:mainfrom
zfy0701:codex/fix-prompt-usage
Open

fix: report full per-prompt token usage#353
zfy0701 wants to merge 1 commit into
agentclientprotocol:mainfrom
zfy0701:codex/fix-prompt-usage

Conversation

@zfy0701

@zfy0701 zfy0701 commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • derive PromptResponse.usage from the cumulative token delta across the complete ACP prompt
  • keep usage_update.used and quota metadata based on the latest response for context-status compatibility
  • cover completed, cancelled, multi-update, and subsequent-prompt usage behavior

Why

Codex app-server reports both the latest model response usage and cumulative session usage. The adapter currently returns only the latest response, so tool-heavy prompts with multiple model calls substantially under-report their per-turn usage.

The ACP maintainers' direction in claude-agent-acp#390 is that PromptResponse.usage is per-turn. Taking the cumulative total at prompt completion minus its value at prompt start preserves that contract without double-counting across prompts.

Validation

  • npm test — 334 passed, 28 skipped
  • npm run typecheck
  • npm run build

Created by Codex . GPT-5.6 Sol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants